<template>
	<view class="tools">
		<text class="title">常用工具</text>
		<view class="tools_list">
			<block v-for="(item, index) in toolsList" :key="index">
				<view class="tools_item" @click="toPath(item)" v-if="item.show || item.both">
					<image :src="item.iconPath" mode=""></image>
					<text class="text">{{ item.text }}</text>
				</view>
			</block>

		</view>
	</view>
</template>

<script>
export default {
	name: "tools",
	props: {
		shopInfo: {
			default: {},
			typeof: Object
		},
	},
	data() {
		return {
			toolsList: [{
				text: '门店信息',
				iconPath: 'https://mg-print.oss-cn-shenzhen.aliyuncs.com/img/store_info.png',
				path: '/pages/otherPage/storeInfo',
				show: false
			},
			{
				text: '价格设置',
				iconPath: 'https://mg-print.oss-cn-shenzhen.aliyuncs.com/img/price_setting.png',
				path: `/pages/otherPage/priceMange`,
				show: false
			},
			{
				// https://mg-print.oss-cn-shenzhen.aliyuncs.com/img/order.png
				text: '订单管理',
				iconPath: 'https://mg-print.oss-cn-shenzhen.aliyuncs.com/upload/17269138840931277.png',
				path: '/pages/otherPage/orderList',
				show: false
			},
			{
				text: '统计数据',
				iconPath: 'https://mg-print.oss-cn-shenzhen.aliyuncs.com/img/statistics.png',
				path: '/pages/otherPage/statistics',
				show: false
			},
			{
				text: '网点管理',
				iconPath: 'https://mg-print.oss-cn-shenzhen.aliyuncs.com/img/staff.png',
				path: '/pages/otherPage/accountManagement',
				show: false
			},
			{
				text: '商家订单',
				iconPath: 'https://mg-print.oss-cn-shenzhen.aliyuncs.com/img/store_vip.png',
				path: '/pages/otherPage/merchantManagement',
				show: false
			},
			{
				text: '分成明细',
				iconPath: 'https://mg-print.oss-cn-shenzhen.aliyuncs.com/img/finance.png',
				path: '/pages/otherPage/divideInto',
				show: false
			},
			{
				text: '快速提现',
				iconPath: 'https://mg-print.oss-cn-shenzhen.aliyuncs.com/upload/17289823802361079.png',
				path: '/pages/otherPage/cir_commis',
				show: false,
				both: true,
			},
			{
				text: '终端信息',
				iconPath: 'https://mg-print.oss-cn-shenzhen.aliyuncs.com/img/terminal.png',
				path: '/pages/otherPage/terminalManagement',
				show: false
			},
			{
				text: '收益明细',
				iconPath: 'https://mg-print.oss-cn-shenzhen.aliyuncs.com/img/separate_accounts.png',
				path: '/pages/otherPage/incomeDetails',
				show: false
			},
			// {
			// 	text: '绑定代理',
			// 	iconPath: 'https://mg-print.oss-cn-shenzhen.aliyuncs.com/img/store_info.png',
			// 	// path: '/pages/otherPage/cir_commis',
			// 	show: false,
			// 	both: true,
			// },
				// {
				// 	text: '快速登陆',
				// 	iconPath: 'https://mg-print.oss-cn-shenzhen.aliyuncs.com/upload/1726824449056794.png',
				// 	// path: '/pages/otherPage/cir_commis',
				// 	show: false,

				// },
				// {text:'财务',iconPath:'https://mg-print.oss-cn-shenzhen.aliyuncs.com/img/finance.png',path:''},
				// {text:'员工绑定',iconPath:'https://mg-print.oss-cn-shenzhen.aliyuncs.com/img/staff.png',path:''},
			]
		};
	},
	methods: {
		toPath(item) {
			if (item.path) {
				const shoptype = item.ShopType?item.ShopType:'非自营'
				uni.navigateTo({
					url: `${item.path}?ShopID=${this.shopInfo.ShopID}&ID=${this.shopInfo.ID}&Type=${this.shopInfo.Type}&ShopType=${shoptype}`
				})
			} else {
				if (item.text == '绑定代理') {
					this.$emit('addStore')
				} if (item.text == '快速登陆') {
					this.scan()
				}

			}

		},
		scan() {
			console.log('uniapp扫描');
		},

	},
	watch: {
		shopInfo(newValue) {
			console.log('123456', newValue);
			const itemsToShowForBusiness = ['网点管理', '商家订单', '分成明细'];
			this.toolsList.forEach(item => {
				if (newValue.Type == 'Business') {
					item.show = !itemsToShowForBusiness.includes(item.text);
				} else {
					item.show = itemsToShowForBusiness.includes(item.text);
				}
			});
			console.log(this.toolsList);
		}
	}
}
</script>

<style lang="scss" scoped>
.tools_list {
	display: flex;
	flex-wrap: wrap;
	box-sizing: border-box;
	padding: 40rpx 48rpx;
	// justify-content: space-between;

	.tools_item {
		display: flex;
		flex-direction: column;
		margin-right: 50rpx;
		align-items: center;
		margin-bottom: 58rpx;

		&:nth-child(4n) {
			margin-right: 0;
		}

		image {
			width: 80rpx;
			height: 80rpx;
			margin-bottom: 18rpx;
		}

		.text {
			font-weight: 500;
			font-size: 24rpx;
			color: #333333;
		}
	}

}

.title {
	font-weight: bold;
	font-size: 32rpx;
	color: #333333;
}

.tools {
	width: 702rpx;
	// height: 662rpx;
	background: #FFFFFF;
	border-radius: 24rpx;
	box-sizing: border-box;
	padding: 32rpx;
	padding-bottom: 0;
	margin: 0 auto;
	margin-top: 24rpx;
}
</style>